package com.blex.misp.entity;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

/**
 * Product generated by hbm2java
 * @author blex
 */
@Entity
@Table(name = "product", catalog = "misp", uniqueConstraints = @UniqueConstraint(columnNames = "PRODUCTNO"))
@DynamicInsert(true)
@DynamicUpdate(true)
public class Product implements java.io.Serializable {

	private Integer id;
	private ProductType producttype;
	private String productno;
	private String productname;
	private String description;
	private double price;

	public Product() {
	}

	public Product(ProductType producttype, String productno,
			String productname, double price) {
		this.producttype = producttype;
		this.productno = productno;
		this.productname = productname;
		this.price = price;
	}

	public Product(ProductType producttype, String productno,
			String productname, String description, double price) {
		this.producttype = producttype;
		this.productno = productno;
		this.productname = productname;
		this.description = description;
		this.price = price;
	}

	@Id
	@Column(name = "ID", unique = true, nullable = false)
	@GeneratedValue(generator = "generator") 
	@GenericGenerator(name = "generator", strategy = "identity")
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	
	@Transient
	@ManyToOne(fetch = FetchType.LAZY, optional=true)
	@JoinColumn(name = "PRODUCTTYPE_ID")
	public ProductType getProducttype() {
		return this.producttype;
	}

	public void setProducttype(ProductType producttype) {
		this.producttype = producttype;
	}

	@Column(name = "PRODUCTNO", unique = true, nullable = false, length = 36)
	public String getProductno() {
		return this.productno;
	}

	public void setProductno(String productno) {
		this.productno = productno;
	}

	@Column(name = "PRODUCTNAME", nullable = false, length = 36)
	public String getProductname() {
		return this.productname;
	}

	public void setProductname(String productname) {
		this.productname = productname;
	}

	@Column(name = "DESCRIPTION", length = 100)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "PRICE", nullable = false, precision = 22, scale = 0)
	public double getPrice() {
		return this.price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

}
